package com.caszx.chargingpile.holder.user;

import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import com.app.base.adapter.holder.BaseHolder;
import com.caszx.chargingpile.R;
import com.caszx.chargingpile.entity.EntityStoreupOrders;

import java.text.DecimalFormat;

/**
 * 订单记录->预约订单
 */
public class OrderReservateHolder extends BaseHolder<EntityStoreupOrders> {


    private TextView  txt_title;
    private TextView  txt_time;
    private TextView  txt_status_reservate;

    private DecimalFormat decimalFormat = new DecimalFormat("###.##");
    public OrderReservateHolder(View view) {
        super(view);
    }

    @Override
    protected void initView() {

        txt_title = (TextView) mRootView.findViewById(R.id.txt_title);
        txt_time = (TextView) mRootView.findViewById(R.id.txt_time);
        txt_status_reservate = (TextView) mRootView.findViewById(R.id.txt_status_reservate);
    }

    @Override
    protected void refreshView() {

        SpannableStringBuilder builder = new SpannableStringBuilder();
        builder.append(mItem.date);
        int start = builder.length();
        builder.append("  ￥"+decimalFormat.format(mItem.totalFees));
        builder.setSpan(new ForegroundColorSpan(mRootView.getResources().getColor(R.color.colorAccent)),start,builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        txt_title.setText(mItem.stationName);
        txt_time.setText(builder);
        txt_status_reservate.setText(mItem.status);


    }
}
